package OSdesign.GUI_show;

import OSdesign.Function_show.*;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;

public class Menu extends JFrame{
    public JPanel panel;
    JLabel label;
    JMenuItem[] m1;
    JMenuItem[] m2;
    JMenuItem[] m3;
    JMenuItem[] m4;

    public Menu(){
        //构造函数

    }
    public void mainMenu(){
        //字体设置
        Font font = new Font("楷体",Font.PLAIN,24);
        Font fonts = new Font("楷体",Font.PLAIN,18);
        //定义 表格的相关组件
        JScrollPane scrollPane = new JScrollPane();
        JTable[] table = new JTable[10];
        DefaultTableModel tableModel = new DefaultTableModel();
        //最底层面板
        panel = new JPanel();
        panel.setBounds(400, 200, 1000,700);
        panel.setBackground(Color.pink);
        panel.setLayout(null);
        //第一个界面面板
        JPanel panel1 = new JPanel();
        panel1.setBounds(0, 0, 1000,700);
        panel1.setBackground(Color.pink);
        panel1.setLayout(null);
        //菜单项1_1面板  比赛设置
        JPanel panel1_1 = new JPanel();
        panel1_1.setLayout(null);
        panel1_1.setBounds(0, 0, 1000,700);
        //菜单项1_2面板  运动员（报名）信息
        JPanel panel1_2 = new JPanel();
        panel1_2.setLayout(null);
        panel1_2.setBounds(0, 0, 1000,700);
        //菜单项1_3面板  名次判定八大按钮
        JPanel panel1_3 = new JPanel();
        panel1_3.setLayout(null);
        panel1_3.setBounds(0, 0, 1000,700);
        //菜单项1_4面板  名词判定表格
        JPanel panel1_4 = new JPanel();
        panel1_4.setLayout(null);
        panel1_4.setBounds(0, 0, 1000,700);
        //菜单项1_5面板  自动分组分道表格
        JPanel panel1_5 = new JPanel();
        panel1_5.setLayout(null);
        panel1_5.setBounds(0, 0, 1000,700);
        //菜单项1_6面板  自动分组分道
        JPanel panel1_6 = new JPanel();
        panel1_6.setLayout(null);
        panel1_6.setBounds(0, 0, 1000,700);
        //成绩查询面板  通过运动员号查询
        JPanel panel3 = new JPanel();
        panel3.setLayout(null);
        panel3.setBounds(0, 0, 1000,700);
        //成绩查询面板  装入表格
        JPanel panel3_1 = new JPanel();
        panel3_1.setLayout(null);
        panel3_1.setBounds(0, 0, 1000,700);
        //团体总分 表格面板
        JPanel panel3_2 = new JPanel();
        panel3_2.setLayout(null);
        panel3_2.setBounds(0, 0, 1000,700);
        //破纪录查询 表格面板
        JPanel panel3_3 = new JPanel();
        panel3_3.setLayout(null);
        panel3_3.setBounds(0, 0, 1000,700);
        //奖牌榜面板  装表格
        JPanel panel4_1 = new JPanel();
        panel4_1.setLayout(null);
        panel4_1.setBounds(0, 0, 1000,700);


        //菜单组件设置
        JMenuBar menuBar = new JMenuBar();
        JMenu menu1 = new JMenu("1.赛前准备");
        JMenu menu2 = new JMenu("2.比赛管理");
        JMenu menu3 = new JMenu("3.查询");
        JMenu menu4 = new JMenu("4.打印");
        JMenu menu5 = new JMenu("5.退出");
        m1 = new JMenuItem[4];     m2 = new JMenuItem[2];
        m3 = new JMenuItem[3];     m4 = new JMenuItem[5];
        m1[0] = new JMenuItem("比赛设置");
        m1[1] = new JMenuItem("运动员报名");
        m1[2] = new JMenuItem("分组分道");
        m1[3] = new JMenuItem("参赛人员信息");
        m2[0] = new JMenuItem("成绩录入");
        m2[1] = new JMenuItem("名次判定");
        m3[0] = new JMenuItem("成绩查询");
        m3[1] = new JMenuItem("团体总分查询");
        m3[2] = new JMenuItem("破纪录查询");
        m4[0] = new JMenuItem("打印检录表");
        m4[1] = new JMenuItem("打印成绩单");
        m4[2] = new JMenuItem("打印奖牌榜");
        m4[3] = new JMenuItem("打印破纪录表");
        //将菜单项添加到菜单
        menu1.add(m1[0]);   menu1.add(m1[1]);   menu1.add(m1[2]);   menu1.add(m1[3]);
        menu2.add(m2[0]);   menu2.add(m2[1]);
        menu3.add(m3[0]);   menu3.add(m3[1]);   menu3.add(m3[2]);
        menu4.add(m4[0]);   menu4.add(m4[1]);   menu4.add(m4[2]);   menu4.add(m4[3]);
        //菜单添加到菜单栏
        menuBar.add(menu1);   menuBar.add(menu2);   menuBar.add(menu3);   menuBar.add(menu4);   menuBar.add(menu5);
        //菜单项 比赛设置点击监听
        m1[0].addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String idea = e.getActionCommand();
                if(idea.equals("比赛设置")){
                    String[] data = {"比赛编号","比赛名称","比赛规则","比赛最好记录"};
                    Object[][] dataDetail = new MatchManager().CompetitionSet();//接受数据库数据
                    //tableModel.setColumnIdentifiers(data);//给表格加标题头
                    tableModel.setDataVector(dataDetail,data);
                    table[0] = new JTable();
                    table[0].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                    table[0].setModel(tableModel);
                    //将表格加入滚动条窗口
                    JScrollPane scrollPane = new JScrollPane(table[0]);
                    scrollPane.setBounds(0,0,980,500);
                    panel1_1.add(scrollPane);
                    //切换有表格的界面
                    panel.removeAll();
                    panel.add(panel1_1);
                    panel.validate();
                    panel.repaint();
                }
            }
        });

        m1[1].addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String idea = e.getActionCommand();
                if(idea.equals("运动员报名")){
                    panel.removeAll();
                    panel.add(panel1);
                    panel.validate();
                    panel.repaint();
                    new Menu_one().applyView();
                }
            }
        });
        m1[2].addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String idea = e.getActionCommand();
                if(idea.equals("分组分道")){
                    panel.removeAll();
                    panel.add(panel1_6);
                    panel.validate();
                    panel.repaint();
                }
            }
        });
        m1[3].addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String idea = e.getActionCommand();
                if(idea.equals("参赛人员信息")){
                    String[] data = {"运动员编号","运动员名称","性别","所属团队","参赛项目"};
                    Object[][] dataDetail = new MatchManager().playerSet();//接受数据库数据
                    //tableModel.setColumnIdentifiers(data);//给表格加标题头
                    tableModel.setDataVector(dataDetail,data);
                    table[1] = new JTable();
                    table[1].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                    table[1].setModel(tableModel);
                    //将表格加入滚动条窗口
                    JScrollPane scrollPane = new JScrollPane(table[1]);
                    scrollPane.setBounds(0,0,980,500);
                    panel1_2.add(scrollPane);
                    //切换有表格的界面
                    panel.removeAll();
                    panel.add(panel1_2);
                    panel.validate();
                    panel.repaint();
                }
            }
        });

        //第二个菜单按钮的二个菜单项组件监听
        m2[0].addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String idea = e.getActionCommand();
                if(idea.equals("成绩录入")){
                    //调用第二打菜单 reportView
                    panel.removeAll();
                    panel.add(panel1);
                    panel.validate();
                    panel.repaint();
                    new Menu_two().inputView();
                }
            }
        });
        m2[1].addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String idea = e.getActionCommand();
                if(idea.equals("名次判定")){
                    panel.removeAll();
                    panel.add(panel1_3);
                    panel.validate();
                    panel.repaint();
                }
            }
        });
        //第三个菜单 三个菜单栏功能监听
        m3[0].addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String idea = e.getActionCommand();
                if(idea.equals("成绩查询")){
                    panel.removeAll();
                    panel.add(panel3);
                    panel.validate();
                    panel.repaint();
                }
            }
        });
        m3[1].addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String idea = e.getActionCommand();
                if(idea.equals("团体总分查询")){
                    String[] data = {"排名","团队名称","总积分"};
                    Object[][] dataDetail = new InquireManager().teamScoreInquire();//接受数据库数据
                    tableModel.setDataVector(dataDetail,data);
                    table[4] = new JTable();
                    table[4].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                    table[4].setModel(tableModel);
                    //将表格加入滚动条窗口
                    JScrollPane scrollPane = new JScrollPane(table[4]);
                    scrollPane.setBounds(0,0,980,500);
                    panel3_2.add(scrollPane);
                    //切换有表格的界面
                    panel.removeAll();
                    panel.add(panel3_2);
                    panel.validate();
                    panel.repaint();
                }
            }
        });
        m3[2].addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String idea = e.getActionCommand();
                if(idea.equals("破纪录查询")){
                    String[] data = {"序号","运动员号","运动员姓名","比赛名称","记录"};
                    Object[][] dataDetail = new InquireManager().breakRecordInquire();//接受数据库数据
                    tableModel.setDataVector(dataDetail,data);
                    table[5] = new JTable();
                    table[5].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                    table[5].setModel(tableModel);
                    //将表格加入滚动条窗口
                    JScrollPane scrollPane = new JScrollPane(table[5]);
                    scrollPane.setBounds(0,0,980,500);
                    panel3_3.add(scrollPane);
                    //切换有表格的界面
                    panel.removeAll();
                    panel.add(panel3_3);
                    panel.validate();
                    panel.repaint();
                }
            }
        });
        //第四个菜单 四个菜单栏功能监听
        m4[0].addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String idea = e.getActionCommand();
                if(idea.equals("打印检录表")){
                    String[] data = {"运动员号","运动员姓名","组号","道号"};
                    Object[][] dataDetail = new MatchManager().autoAllot_100();//接受数据库数据
                    tableModel.setDataVector(dataDetail,data);
                    table[6] = new JTable();
                    table[6].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                    table[6].setModel(tableModel);
                    //将表格加入滚动条窗口
                    JScrollPane scrollPane = new JScrollPane(table[6]);
                    scrollPane.setBounds(0,0,980,500);
                    panel1_5.add(scrollPane);
                    //切换有表格的界面
                    panel.removeAll();
                    panel.add(panel1_5);
                    panel.validate();
                    panel.repaint();
                    new OutputManager().printCheck();
                    JOptionPane.showMessageDialog(null,"成功导出报表！");
                }
            }
        });
        m4[1].addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String idea = e.getActionCommand();
                if(idea.equals("打印成绩单")){
                    String[] data = {"运动员编号","比赛编号","所属团队","成绩","获奖情况","个人积分"};
                    Object[][] dataDetail = new InquireManager().gradeInquire();//接受数据库数据
                    tableModel.setDataVector(dataDetail,data);
                    table[3] = new JTable();
                    table[3].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                    table[3].setModel(tableModel);
                    //将表格加入滚动条窗口
                    JScrollPane scrollPane = new JScrollPane(table[3]);
                    scrollPane.setBounds(0,0,980,500);
                    panel3_1.add(scrollPane);
                    //切换有表格的界面
                    panel.removeAll();
                    panel.add(panel3_1);
                    panel.validate();
                    panel.repaint();
                    new OutputManager().printGrade();
                    JOptionPane.showMessageDialog(null,"成功导出报表！");
                }
            }
        });
        m4[2].addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String idea = e.getActionCommand();
                if(idea.equals("打印奖牌榜")){
                    String[] data = {"名次","团队名称","团体总积分","金牌","银牌","铜牌"};
                    Object[][] dataDetail = new OutputManager().medalsTotal();//接受数据库数据
                    tableModel.setDataVector(dataDetail,data);
                    table[9] = new JTable();
                    table[9].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                    table[9].setModel(tableModel);
                    //将表格加入滚动条窗口
                    JScrollPane scrollPane = new JScrollPane(table[9]);
                    scrollPane.setBounds(0,0,980,500);
                    panel4_1.add(scrollPane);
                    //切换有表格的界面
                    panel.removeAll();
                    panel.add(panel4_1);
                    panel.validate();
                    panel.repaint();
                    new OutputManager().printMedal();
                    JOptionPane.showMessageDialog(null,"成功导出报表！");
                }
            }
        });
        m4[3].addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String idea = e.getActionCommand();
                if(idea.equals("打印破纪录表")){
                    String[] data = {"序号","运动员号","运动员姓名","比赛名称","记录"};
                    Object[][] dataDetail = new InquireManager().breakRecordInquire();//接受数据库数据
                    tableModel.setDataVector(dataDetail,data);
                    table[5] = new JTable();
                    table[5].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                    table[5].setModel(tableModel);
                    //将表格加入滚动条窗口
                    JScrollPane scrollPane = new JScrollPane(table[5]);
                    scrollPane.setBounds(0,0,980,500);
                    panel3_3.add(scrollPane);
                    //切换有表格的界面
                    panel.removeAll();
                    panel.add(panel3_3);
                    panel.validate();
                    panel.repaint();
                    new InquireManager().breakRecordInquire();
                    JOptionPane.showMessageDialog(null,"成功导出报表！");
                }
            }
        });
        //菜单上的退出按钮监听，并执行退出
        menu5.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                super.mouseClicked(e);
                new MySQL_Conn().disConnect();
                System.exit(0);
            }
        });


        //菜单字体设置
        //menuBar.setFont(font);
        menu1.setFont(font);  m1[0].setFont(font);  m1[1].setFont(font);  m1[2].setFont(font);  m1[3].setFont(font);
        menu2.setFont(font);  m2[0].setFont(font);  m2[1].setFont(font);
        menu3.setFont(font);  m3[0].setFont(font);  m3[1].setFont(font);  m3[2].setFont(font);
        menu4.setFont(font);  m4[0].setFont(font);  m4[1].setFont(font);  m4[2].setFont(font);  m4[3].setFont(font);
        menu5.setFont(font);


        //第一个初始面板 panel1 上的标签
        label = new JLabel("欢迎使用田径运动会管理系统");
        label.setFont(new Font("",Font.BOLD,55));
        label.setBounds(120,-70,800,200);
        JLabel labell = new JLabel("友谊第一");
        labell.setFont(new Font("",Font.BOLD,55));
        labell.setBounds(200,100,800,200);
        JLabel labelr = new JLabel("比赛第二");
        labelr.setFont(new Font("",Font.BOLD,55));
        labelr.setBounds(500,300,800,200);



        //设置比赛信息界面的按钮
        JButton addButton = new JButton("添加比赛");
        addButton.setFont(fonts);
        addButton.setBounds(100,550,120,40);
        addButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //执行Menu_one中 修改比赛界面 函数
                new Menu_one().addView();
            }
        });
        //点击进入比赛规则修改界面
        JButton ediButton = new JButton("修改规则");
        ediButton.setFont(fonts);
        ediButton.setBounds(250,550,120,40);
        ediButton.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                super.mouseClicked(e);
                //执行Menu_one中 修改规则界面
                new Menu_one().ediView();
            }
        });
        JButton delButton = new JButton("删除比赛");
        delButton.setFont(fonts);
        delButton.setBounds(400,550,120,40);
        JButton confirmButton = new JButton("确定");
        confirmButton.setFont(fonts);
        confirmButton.setBounds(550,550,120,40);

        panel1.add(label);
        panel1.add(labell);
        panel1.add(labelr);

        //成绩查询 设置组件，通过运动号查询
        JLabel pnoLabel = new JLabel("输入你的编号");
        pnoLabel.setFont(font);
        pnoLabel.setBounds(200,200,200,50);
        JTextField pnoField = new JTextField();
        pnoField.setFont(fonts);
        pnoField.setBounds(400,200,300,50);
        JButton askButton = new JButton("查询");
        askButton.setFont(fonts);
        askButton.setBounds(500,400,150,50);
        askButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String str = pnoField.getText();
                String[] data = {"运动员编号","比赛编号","所属团队","成绩","获奖情况","个人积分"};
                Object[][] dataDetail = new InquireManager().gradeAsk(str);//接受数据库数据
                tableModel.setDataVector(dataDetail,data);
                table[3] = new JTable();
                table[3].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                table[3].setModel(tableModel);
                //将表格加入滚动条窗口
                JScrollPane scrollPane = new JScrollPane(table[3]);
                scrollPane.setBounds(0,0,980,500);
                panel3_1.add(scrollPane);
                //切换有表格的界面
                panel.removeAll();
                panel.add(panel3_1);
                panel.validate();
                panel.repaint();
            }
        });
        panel3.add(pnoLabel);
        panel3.add(pnoField);
        panel3.add(askButton);

        //分组分道按钮 3个跑步
        JButton track_100 = new JButton("男子100米短跑");
        track_100.setFont(fonts);
        track_100.setBounds(300,100,200,50);
        track_100.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String[] data = {"运动员号","运动员姓名","组号","道号"};
                Object[][] dataDetail = new MatchManager().autoAllot_100();//接受数据库数据
                tableModel.setDataVector(dataDetail,data);
                table[6] = new JTable();
                table[6].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                table[6].setModel(tableModel);
                //将表格加入滚动条窗口
                JScrollPane scrollPane = new JScrollPane(table[6]);
                scrollPane.setBounds(0,0,980,500);
                panel1_5.add(scrollPane);
                //切换有表格的界面
                panel.removeAll();
                panel.add(panel1_5);
                panel.validate();
                panel.repaint();
            }
        });
        JButton track_1500 = new JButton("男子1500米长跑");
        track_1500.setFont(fonts);
        track_1500.setBounds(300,250,200,50);
        track_1500.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String[] data = {"运动员号","运动员姓名","组号","道号"};
                Object[][] dataDetail = new MatchManager().autoAllot_1500();//接受数据库数据
                tableModel.setDataVector(dataDetail,data);
                table[7] = new JTable();
                table[7].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                table[7].setModel(tableModel);
                //将表格加入滚动条窗口
                JScrollPane scrollPane = new JScrollPane(table[7]);
                scrollPane.setBounds(0,0,980,500);
                panel1_5.add(scrollPane);
                //切换有表格的界面
                panel.removeAll();
                panel.add(panel1_5);
                panel.validate();
                panel.repaint();
            }
        });
        JButton track_400 = new JButton("女子400米短跑");
        track_400.setFont(fonts);
        track_400.setBounds(300,400,200,50);
        track_400.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String[] data = {"运动员号","运动员姓名","组号","道号"};
                Object[][] dataDetail = new MatchManager().autoAllot_400();//接受数据库数据
                tableModel.setDataVector(dataDetail,data);
                table[8] = new JTable();
                table[8].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                table[8].setModel(tableModel);
                //将表格加入滚动条窗口
                JScrollPane scrollPane = new JScrollPane(table[8]);
                scrollPane.setBounds(0,0,980,500);
                panel1_5.add(scrollPane);
                //切换有表格的界面
                panel.removeAll();
                panel.add(panel1_5);
                panel.validate();
                panel.repaint();
            }
        });
        panel1_6.add(track_100);
        panel1_6.add(track_400);
        panel1_6.add(track_1500);
        //名词判定按钮设置
        JButton run_100 = new JButton("男子100米短跑");
        run_100.setFont(fonts);
        run_100.setBounds(120,100,200,50);
        run_100.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Object[][] dataDetail = new PlayerManager().rankGrade_run("男子100米短跑");
                String[] data = {"排名","运动员号","比赛编号","成绩"};
                tableModel.setDataVector(dataDetail,data);
                table[2] = new JTable();
                table[2].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                table[2].setModel(tableModel);
                //将表格加入滚动条窗口
                JScrollPane scrollPane = new JScrollPane(table[2]);
                scrollPane.setBounds(0,0,980,500);
                panel1_4.add(scrollPane);
                panel.removeAll();
                panel.add(panel1_4);
                panel.validate();
                panel.repaint();
            }
        });
        JButton run_400 = new JButton("女子400米短跑");
        run_400.setFont(fonts);
        run_400.setBounds(400,100,200,50);
        run_400.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Object[][] dataDetail = new PlayerManager().rankGrade_run("女子400米短跑");
                String[] data = {"排名","运动员号","比赛编号","成绩"};
                tableModel.setDataVector(dataDetail,data);
                table[2] = new JTable();
                table[2].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                table[2].setModel(tableModel);
                //将表格加入滚动条窗口
                JScrollPane scrollPane = new JScrollPane(table[2]);
                scrollPane.setBounds(0,0,980,500);
                panel1_4.add(scrollPane);
                panel.removeAll();
                panel.add(panel1_4);
                panel.validate();
                panel.repaint();
            }
        });
        JButton jump1 = new JButton("跳高");
        jump1.setFont(fonts);
        jump1.setBounds(120,200,200,50);
        jump1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Object[][] dataDetail = new PlayerManager().rankGrade_unrun("跳高");
                String[] data = {"排名","运动员号","比赛编号","成绩"};
                tableModel.setDataVector(dataDetail,data);
                table[2] = new JTable();
                table[2].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                table[2].setModel(tableModel);
                //将表格加入滚动条窗口
                JScrollPane scrollPane = new JScrollPane(table[2]);
                scrollPane.setBounds(0,0,980,500);
                panel1_4.add(scrollPane);
                panel.removeAll();
                panel.add(panel1_4);
                panel.validate();
                panel.repaint();
            }
        });
        JButton jump2 = new JButton("跳远");
        jump2.setFont(fonts);
        jump2.setBounds(400,200,200,50);
        jump2.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Object[][] dataDetail = new PlayerManager().rankGrade_unrun("跳远");
                String[] data = {"排名","运动员号","比赛编号","成绩"};
                tableModel.setDataVector(dataDetail,data);
                table[2] = new JTable();
                table[2].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                table[2].setModel(tableModel);
                //将表格加入滚动条窗口
                JScrollPane scrollPane = new JScrollPane(table[2]);
                scrollPane.setBounds(0,0,980,500);
                panel1_4.add(scrollPane);
                panel.removeAll();
                panel.add(panel1_4);
                panel.validate();
                panel.repaint();
            }
        });
        JButton jump3 = new JButton("撑杆跳高");
        jump3.setFont(fonts);
        jump3.setBounds(120,300,200,50);
        jump3.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Object[][] dataDetail = new PlayerManager().rankGrade_unrun("撑杆跳高");
                String[] data = {"排名","运动员号","比赛编号","成绩"};
                tableModel.setDataVector(dataDetail,data);
                table[2] = new JTable();
                table[2].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                table[2].setModel(tableModel);
                //将表格加入滚动条窗口
                JScrollPane scrollPane = new JScrollPane(table[2]);
                scrollPane.setBounds(0,0,980,500);
                panel1_4.add(scrollPane);
                panel.removeAll();
                panel.add(panel1_4);
                panel.validate();
                panel.repaint();
            }
        });
        JButton ball = new JButton("铅球");
        ball.setFont(fonts);
        ball.setBounds(400,300,200,50);
        ball.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Object[][] dataDetail = new PlayerManager().rankGrade_unrun("铅球");
                String[] data = {"排名","运动员号","比赛编号","成绩"};
                tableModel.setDataVector(dataDetail,data);
                table[2] = new JTable();
                table[2].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                table[2].setModel(tableModel);
                //将表格加入滚动条窗口
                JScrollPane scrollPane = new JScrollPane(table[2]);
                scrollPane.setBounds(0,0,980,500);
                panel1_4.add(scrollPane);
                panel.removeAll();
                panel.add(panel1_4);
                panel.validate();
                panel.repaint();
            }
        });
        JButton gun = new JButton("标枪");
        gun.setFont(fonts);
        gun.setBounds(120,400,200,50);
        gun.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Object[][] dataDetail = new PlayerManager().rankGrade_unrun("标枪");
                String[] data = {"排名","运动员号","比赛编号","成绩"};
                tableModel.setDataVector(dataDetail,data);
                table[2] = new JTable();
                table[2].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                table[2].setModel(tableModel);
                //将表格加入滚动条窗口
                JScrollPane scrollPane = new JScrollPane(table[2]);
                scrollPane.setBounds(0,0,980,500);
                panel1_4.add(scrollPane);
                panel.removeAll();
                panel.add(panel1_4);
                panel.validate();
                panel.repaint();
            }
        });
        JButton discus = new JButton("铁饼");
        discus.setFont(fonts);
        discus.setBounds(400,400,200,50);
        discus.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Object[][] dataDetail = new PlayerManager().rankGrade_unrun("铁饼");
                String[] data = {"排名","运动员号","比赛编号","成绩"};
                tableModel.setDataVector(dataDetail,data);
                table[2] = new JTable();
                table[2].setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
                table[2].setModel(tableModel);
                //将表格加入滚动条窗口
                JScrollPane scrollPane = new JScrollPane(table[2]);
                scrollPane.setBounds(0,0,980,500);
                panel1_4.add(scrollPane);
                panel.removeAll();
                panel.add(panel1_4);
                panel.validate();
                panel.repaint();
            }
        });
        panel1_3.add(run_100);
        panel1_3.add(run_400);
        panel1_3.add(jump1);
        panel1_3.add(jump2);
        panel1_3.add(jump3);
        panel1_3.add(ball);
        panel1_3.add(gun);
        panel1_3.add(discus);

        panel1_1.add(addButton);
        panel1_1.add(ediButton);
        panel.add(panel1);

        this.add(panel);
        this.setFocusable(true);//初始焦点不可见
        this.setResizable(false);//窗口尺寸不可改变
        this.setBounds(400, 200, 1000,700);
        this.setJMenuBar(menuBar);//添加惨淡栏
        this.setVisible(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setTitle("田径运动会管理系统");

    }

    public static void main(String[] args){
        Menu m = new Menu();
        m.mainMenu();
    }
}
